package com.syezon.wifikey.speed.config;

import com.blankj.utilcode.util.SPUtils;
import com.syezon.wifikey.BuildConfig;

import java.util.Date;

public class SpeedConfig {

    public static int DEFAULT_FREE_COUNT = 2;
    private static final String CONFIG_NAME = "speed_test_config";
    private static final String SPEED_TEST_URL = "speed_test_url";
    private static final String FREE_TEST_COUNT = "free_test_count";
    private static final String PER_DAY_FREE_TEST_COUNT = "per_day_free_test_count";
    private static final String TODAY_ADD_COUNT = "today_add_count";
    private static final String DATE_FREE_TEST_COUNT = "date_free_test_count";

    static {
        if (BuildConfig.DEBUG) {
            DEFAULT_FREE_COUNT = 100;
        } else {
            DEFAULT_FREE_COUNT = 2;
        }
    }

    /**
     * @return 每天免费次数
     */
    public static int getFreeTestCountPerDay() {
        return SPUtils.getInstance(CONFIG_NAME).getInt(PER_DAY_FREE_TEST_COUNT, DEFAULT_FREE_COUNT);
    }

    public static void saveFreeTestCountPerDay(int count) {
        SPUtils.getInstance(CONFIG_NAME).put(PER_DAY_FREE_TEST_COUNT, count);
    }


    public static String getSpeedTestUrl() {
        return SPUtils.getInstance(CONFIG_NAME).getString(SPEED_TEST_URL, "http://static.iqiyi.com/ext/common/IQIYIsetup_appstore.exe");
    }

    public static void saveSpeedTestUrl(String url) {
        SPUtils.getInstance(CONFIG_NAME).put(SPEED_TEST_URL, url);
    }

}
